from django.views.generic import ListView, DetailView, CreateView, \
                                 DeleteView, UpdateView, \
                                 ArchiveIndexView, DateDetailView, \
                                 DayArchiveView, MonthArchiveView, \
                                 TodayArchiveView, WeekArchiveView, \
                                 YearArchiveView


from weather.models import UserPersonal


class UserPersonalView(object):
    model = UserPersonal

    def get_template_names(self):
        """Nest templates within userpersonal directory."""
        tpl = super(UserPersonalView, self).get_template_names()[0]
        app = self.model._meta.app_label
        mdl = 'userpersonal'
        self.template_name = tpl.replace(app, '{0}/{1}'.format(app, mdl))
        return [self.template_name]


class UserPersonalDateView(UserPersonalView):
    date_field = 'regtime'
    month_format = '%m'


class UserPersonalBaseListView(UserPersonalView):
    paginate_by = 10


class UserPersonalArchiveIndexView(
    UserPersonalDateView, UserPersonalBaseListView, ArchiveIndexView):
    pass


class UserPersonalCreateView(UserPersonalView, CreateView):
    pass


class UserPersonalDateDetailView(UserPersonalDateView, DateDetailView):
    pass


class UserPersonalDayArchiveView(
    UserPersonalDateView, UserPersonalBaseListView, DayArchiveView):
    pass


class UserPersonalDeleteView(UserPersonalView, DeleteView):

    def get_success_url(self):
        from django.core.urlresolvers import reverse
        return reverse('weather_userpersonal_list')


class UserPersonalDetailView(UserPersonalView, DetailView):
    pass


class UserPersonalListView(UserPersonalBaseListView, ListView):
    pass


class UserPersonalMonthArchiveView(
    UserPersonalDateView, UserPersonalBaseListView, MonthArchiveView):
    pass


class UserPersonalTodayArchiveView(
    UserPersonalDateView, UserPersonalBaseListView, TodayArchiveView):
    pass


class UserPersonalUpdateView(UserPersonalView, UpdateView):
    pass


class UserPersonalWeekArchiveView(
    UserPersonalDateView, UserPersonalBaseListView, WeekArchiveView):
    pass


class UserPersonalYearArchiveView(
    UserPersonalDateView, UserPersonalBaseListView, YearArchiveView):
    make_object_list = True



